package com.itheima.service;

import com.itheima.dao.UserDao;
import com.itheima.pojo.Address;
import com.itheima.pojo.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class UserServiceImplA implements UserService{

    //创建UserDao对象
    //@Autowired
    //@Qualifier("userDaoImplB")
    @Resource(name = "userDaoImplB")
    private UserDao userDao;

    public List<User> listUser() {
        List<User> data = userDao.listUser();
        //2 加工数据将省市，区县加上（业务逻辑）
        for (User user : data) {
            Address address = user.getAddress();
            address.setProvince(address.getProvince()+"（省,市）");
            address.setCity(address.getCity()+"(区，县)");
        }
        //3.返回给Controller
        return data;
    }
}
